//店铺授权之前购买服务确认

import React, { useEffect } from "react";
import { CommonModal } from "@/views/components/CommonModal";
import { Button, Form, Radio } from "antd";
import { renderRoleType } from "@/utils/utils.jsx";
import useSettingStore from "@/stores/setting";

//获取用户角色类型
const roleType = renderRoleType();

const BuyConfirm = ({ visible, selectItem, isJumpLogin, handleOk, handleCancel }) => {
	const title = useSettingStore(state => state.title);

	const [form] = Form.useForm();

	//跳转到应用购买页面
	const handleBuyService = () => {
		const pathArr = [
			{
				platform: "8",
				src:
					title == "易发货"
						? "https://fuwu.taobao.com/ser/detail.htm?service_code=FW_GOODS-1001122201&spm=a1z13.1113647.0.0.20cd5acaLk4YHV&code=FW_GOODS-1001122201"
						: "https://fuwu.taobao.com/ser/detail.htm?service_code=FW_GOODS-1000239806&code=FW_GOODS-1000239806"
			}, //淘宝
			{ platform: "18", src: "https://fuwu.taobao.com/ser/detail.htm?service_code=FW_GOODS-1000239806&code=FW_GOODS-1000239806" }, //天猫
			{ platform: "19", src: "https://fuwu.taobao.com/ser/detail.htm?service_code=FW_GOODS-1000239806&code=FW_GOODS-1000239806" }, //京东云仓
			{ platform: "1", src: "https://fw.jd.com/main/detail/FW_GOODS-258815" }, //京东
			{ platform: "15", src: "https://fuwu.jinritemai.com/detail?from=open_partner_svcList&service_id=1965" }, //抖音
			{ platform: "12", src: "https://fuwu.kwaixiaodian.com/detail?id=938934573299" }, //快手
			{
				platform: "9",
				src: "https://mms.pinduoduo.com/login/sso?platform=fuwu&redirectUrl=https://fuwu.pinduoduo.com/clint/api/login?redirect=https://fuwu.pinduoduo.com/service-market/service-detail?detailId=86856"
			} //拼多多
		];
		let path;
		path = pathArr.filter(v => v.platform == selectItem.platform)[0].src;
		window.open(path);
		// if(selectItem.platform != '9'){
		//     window.open(path);
		// }
	};

	const handleClick = () => {
		handleOk();
	};

	return (
		<CommonModal
			title={{ title: "应用服务购买确认" }}
			visible={visible}
			width="449px"
			onCancel={handleCancel}
			minHeight="100px"
			footer={[
				<Button key="save" onClick={handleBuyService}>
					去购买应用
				</Button>,
				<Button key="ok" onClick={handleClick} type="primary">
					开始授权
				</Button>
			]}
		>
			<div className="common-color11" style={{ paddingLeft: "24px" }}>
				<p style={{ marginBottom: "16px" }}>店铺授权前请先在服务市场购买应用服务，购买成功后才能授权店铺</p>
			</div>
		</CommonModal>
	);
};

export default BuyConfirm;
